#ifndef MEMORY_H
#define MEMORY_H
#include <stdint.h>
#include <stdlib.h>
#include "./debug.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
  uint8_t* data;
  uint16_t len;
  uint16_t _bufLenMax;
} MemoryStruct;  // mem结构体

void* mem_alloc(unsigned int size);
#define mem_free(p) \
  {                 \
    free(p);        \
    p = NULL;       \
  }
void* mem_set(void* dst, int c, unsigned int n);
void* mem_cpy(void* dst, const void* src, unsigned int n);
int mem_cmp(const void* dst, const void* src, unsigned int n);

#ifdef __cplusplus
}
#endif
#endif  // MEMORY_H
